#!/usr/bin/env python
'''Escape HTML on a file'''

__author__ =  "Miki Tebeka <miki.tebeka@gmail.com>"
__license__ = "BSD" # see LICENSE

import fileinput
from cgi import escape

def main(argv=None):
    if argv is None:
        import sys
        argv = sys.argv

    from optparse import OptionParser

    parser = OptionParser("usage: %prog [FILENAME]")

    opts, args = parser.parse_args(argv[1:])
    if len(args) != 1:
        parser.error("wrong number of arguments") # Will exit

    for line in fileinput.input():
        print escape(line).rstrip()

if __name__ == "__main__":
    main()
